---
title: 'Completions'
description: 'Monitor OpenAI Completions API Usage'
---

<Tabs>
  <Tab title="Python">
    <CodeGroup>
    ```python No Streaming
    from openai import OpenAI
    import dokumetry

    client = OpenAI(
      api_key = "YOUR_OPENAI_API_KEY"
    )

    # Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
    dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")

    client.completions.create(
      model="gpt-3.5-turbo-instruct",
      prompt="Say this is a test",
      max_tokens=7,
      temperature=0
    )
    ```

    ```python Streaming
    from openai import OpenAI
    import dokumetry

    client = OpenAI(
      api_key = "YOUR_OPENAI_API_KEY"
    )

    # Pass the above `client` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
    dokumetry.init(llm=client, doku_url="YOUR_DOKU_INGESTER_URL", api_key="YOUR_DOKU_TOKEN")

    for chunk in client.completions.create(
      model="gpt-3.5-turbo-instruct",
      prompt="Say this is a test",
      max_tokens=7,
      temperature=0,
      stream=True
    ):

    print(chunk.choices[0].text)
    ```
    </CodeGroup>
  </Tab>
  <Tab title="NodeJS">
    <CodeGroup>
    ```javascript No Streaming
    import OpenAI from "openai";
    import DokuMetry from 'dokumetry';

    const openai = new OpenAI();

    // Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
    DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})

    async function main() {
      const completion = await openai.completions.create({
        model: "gpt-3.5-turbo-instruct",
        prompt: "Say this is a test.",
        max_tokens: 7,
        temperature: 0,
      });

      console.log(completion);
    }
    main();
    ```

    ```javascript Streaming
    import OpenAI from "openai";
    import DokuMetry from 'dokumetry';

    const openai = new OpenAI();

    // Pass the above `openai` object along with your Doku Ingester URL and API key and this will make sure that all OpenAI calls are automatically tracked.
    DokuMetry.init({llm: openai, dokuUrl: "YOUR_DOKU_INGESTER_URL", apiKey: "YOUR_DOKU_TOKEN"})

    async function main() {
      const stream = await openai.completions.create({
        model: "gpt-3.5-turbo-instruct",
        prompt: "Say this is a test.",
        stream: true,
      });

      for await (const chunk of stream) {
        console.log(chunk.choices[0].text)
      }
    }
    main();
    ```
    </CodeGroup>
  </Tab>
</Tabs>